
#include "./inc/uni_config.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <string.h>

#define CONFIG_NAME  "config_file"
#define MODULE_NAME  "rasr"
int main(int argc, char const *argv[]) {
  char *config = NULL;
  char buf[128];

  static long long protocol = 1;
  static double std_threshold;
  int rc;
  /* step 1. initialize */
  ConfigInitialize();
  int count = 1000;
  while(count--) {
    if (-1 == (ConfigReadItemNumber(CONFIG_NAME, "rasr.protocol", &protocol))) {
      printf("%s%d: [%d] %lld\n", __FUNCTION__, __LINE__, rc, protocol);
    }
    if (-1 == (rc = ConfigReadItemDouble(CONFIG_NAME, "lasr.lasr_asr.eng.std_threshold", &std_threshold))) {
      printf("%s%d: [%d] %f\n", __FUNCTION__, __LINE__, rc, std_threshold);
    }
    if (-1 == (rc = ConfigReadItemString(CONFIG_NAME, "rasr.ser.nlu", buf, sizeof(buf)))) {
      printf("%s%d: [%d] %s\n", __FUNCTION__, __LINE__, rc, buf);
    }
    if (-1 == (rc = ConfigWriteItemNumber(CONFIG_NAME, "rasr.protocol", 1111))) {
      printf("%s%d: [%d] %lld\n", __FUNCTION__, __LINE__, rc, protocol);
    }
    if (-1 == (rc = ConfigWriteItemDouble(CONFIG_NAME, "lasr.lasr_asr.eng.std_threshold", -111.111))) {
      printf("%s%d: [%d] %f\n", __FUNCTION__, __LINE__, rc, std_threshold);
    }
    if (-1 == (rc = ConfigWriteItemString(CONFIG_NAME, "rasr.ser.nlu", "hello world hehe", strlen("hello world hehe") + 1))) {
      printf("%s%d: [%d] %f\n", __FUNCTION__, __LINE__, rc, std_threshold);
    }
  }
  /* step 3. finalize*/
  ConfigFinalize();
  return 0;
}
